package com.mogujie.tt.DB.entity;

import android.os.Parcel;
import android.os.Parcelable;

public class PlanEntity implements Parcelable {
    private int id;
    private int type;
    private int year;
    private int ord;
    private String title;
    private String content;
    private String standard;
    private int status;
    private int from_uid;
    private int to_uid;
    private long create_time;
    private int praises;
    private long pass_time;
    private long hope_time;
    private int[] copyfor;
    private int[] comments;

    public PlanEntity() {
        this.title="未命名计划";
    }
    protected PlanEntity(Parcel source) {
        setId(source.readInt());
        setType(source.readInt());
        setYear(source.readInt());
        setOrd(source.readInt());
        setTitle(source.readString());
        setContent(source.readString());
        setStandard(source.readString());
        setStatus(source.readInt());
        setFrom_uid(source.readInt());
        setTo_uid(source.readInt());
        setCreate_time(source.readLong());
        setPraises(source.readInt());
        setPass_time(source.readLong());
        setHope_time(source.readLong());

        int length = source.readInt() ;
        int[] cpArr = null ;
        //如果数组长度大于0，那么就读数组， 所有数组的操作都可以这样。
        if(length>0){
            cpArr = new int[length];
            source.readIntArray(cpArr);
        }
    }


    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel parcel, int i) {
        parcel.writeInt(id);
        parcel.writeInt(type);
        parcel.writeInt(year);
        parcel.writeInt(ord);
        parcel.writeString(title);
        parcel.writeString(content);
        parcel.writeString(standard);
        parcel.writeInt(status);
        parcel.writeInt(from_uid);
        parcel.writeInt(to_uid);
        parcel.writeLong(create_time);
        parcel.writeInt(praises);
        parcel.writeLong(pass_time);
        parcel.writeLong(hope_time);
        // 判断能不能读数组，也就是说下面如果读到的长度是0，那么就不读数组了，否则就创建相同长度的数组去读
        //如果数组为空，就可以不写
        if(copyfor==null){
            parcel.writeInt(0);
        }else{
            parcel.writeInt(copyfor.length);
        }
        if(copyfor!=null){
            parcel.writeIntArray(copyfor);
        }
        if(comments==null){
            parcel.writeInt(0);
        }else{
            parcel.writeInt(comments.length);
        }
        if(comments!=null){
            parcel.writeIntArray(comments);
        }

    }


    public static final Parcelable.Creator<PlanEntity> CREATOR = new Creator(){

        @Override
        public PlanEntity createFromParcel(Parcel source) {
            // TODO Auto-generated method stub
            // 必须按成员变量声明的顺序读取数据，不然会出现获取数据出错
            return new PlanEntity(source);

        }

        @Override
        public PlanEntity[] newArray(int size) {
            return new PlanEntity[size];
        }
    };


    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public int getType() {
        return type;
    }

    public void setType(int type) {
        this.type = type;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public String getStandard() {
        return standard;
    }

    public void setStandard(String standard) {
        this.standard = standard;
    }

    public int getStatus() {
        return status;
    }

    public void setStatus(int status) {
        this.status = status;
    }

    public int getFrom_uid() {
        return from_uid;
    }

    public void setFrom_uid(int from_uid) {
        this.from_uid = from_uid;
    }

    public int getPraises() {
        return praises;
    }

    public void setPraises(int praises) {
        this.praises = praises;
    }


    public long getPass_time() {
        return pass_time;
    }

    public void setPass_time(long pass_time) {
        this.pass_time = pass_time;
    }

    public long getHope_time() {
        return hope_time;
    }

    public void setHope_time(long hope_time) {
        this.hope_time = hope_time;
    }

    public int[] getCopyfor() {
        return copyfor;
    }

    public void setCopyfor(int[] copyfor) {
        this.copyfor = copyfor;
    }
    public int getTo_uid() {
        return to_uid;
    }

    public void setTo_uid(int to_uid) {
        this.to_uid = to_uid;
    }
    public int getYear() {
        return year;
    }

    public void setYear(int year) {
        this.year = year;
    }

    public int getOrd() {
        return ord;
    }

    public void setOrd(int ord) {
        this.ord = ord;
    }
    public int[] getComments() {
        return comments;
    }

    public void setComments(int[] comments) {
        this.comments = comments;
    }
    public long getCreate_time() {
        return create_time;
    }
    public void setCreate_time(long create_time) {
        this.create_time = create_time;
    }
}
